<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>检查任务执行</title>
	<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
	<script type="text/javascript" src="easyui/jquery.min.js"></script>
	<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="检查任务执行" style="width:auto;height:auto"
			data-options="
				singleSelect: true,
				toolbar: '#tb',
				url: 'checklist',
				method: 'get',
				toolbar:'#tb',
				rownumbers:true,
				pagination:true,
				pageSize:10
			">
		<thead>
			<tr>
				<th data-options="field:'id',width:120,hidden:true">ID</th>
				<th data-options="field:'name',width:200">任务名称</th>
				<th data-options="field:'captain',width:80,align:'right'">组长</th>
				<th data-options="field:'member',width:80,align:'left',editor:'numberbox'">成员</th>
				<th data-options="field:'expert',width:80,editor:'textbox'">专家</th>
				<th data-options="field:'entname',width:200,align:'center',editor:'numberbox'">企业名称</th>
				<th data-options="field:'checkItem',width:200,align:'center',editor:'numberbox'">检查事项</th>
				<th data-options="field:'status',width:80,align:'center',formatter:function(value,row){
							return value==0?'未签收':'已签收';
						},editor:'numberbox'">是否签收</th>
				<th data-options="field:'signIn',width:160,align:'center',formatter:function(value,row){
							return value==0?'未签到':'已签到';
						},editor:'numberbox'">是否签到</th>
				<th data-options="field:'acceptName',width:120,align:'center',editor:'numberbox'">任务接收人</th>
				<th data-options="field:'acceptId',width:120,align:'center',editor:'numberbox'">任务接收人</th>
				<th data-options="field:'createTime',width:300,align:'center',editor:'numberbox'">创建时间</th>
			</tr>
		</thead>
	</table>
	 <div id="tb" style="padding:5px;height:auto">
			<div style="margin-bottom:5px">
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">新增检查任务</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="sign()">签到</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除</a>
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">签收</a>
				&nbsp;&nbsp;企业名称: <input class="easyui-textbox" style="width:180px" id="search">
				<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" data-options="iconCls:'icon-search',plain:true" onclick="searchGep()">查询</a>
			</div>
		</div>
	<div id="win" class="easyui-dialog" title="添加无证企业信息"  style="width: 400px; padding: 10px 20px; height: 340px;"
     closed="true" buttons="#dlg-buttons">
 
    <form id="fm" method="post" action="" style="margin-top: 20px; margin-left: 20px;">
        <div class="fitem">
            <label>任务名称:</label>
            <input id="name" style="" name="" class="easyui-textbox" data-options="required:true" />
        </div>
        <div class="fitem">
            <label>检查组长:</label>
			<input id="captain" class="easyui-combogrid" style="width:175px" data-options="
																			panelWidth: 500,
																			idField: 'id',
																			textField: 'name',
																			url: 'bzjcry',
																			method: 'get',
																			rownumbers:true,
																			pagination:true,
																			pageSize:10,
																			columns: [[
																				{field:'id',title:'组长',width:80},
																				{field:'name',title:'姓名',width:120},
																			]],
																			fitColumns: true">
        </div>
        
        <div class="fitem">
            <label>检查组员:</label>
            <input id="member" class="easyui-combogrid" style="width:175px" data-options="
																			panelWidth: 500,
																			idField: 'id',
																			textField: 'name',
																			url: 'bzjcry',
																			method: 'get',
																			rownumbers:true,
																			pagination:true,
																			pageSize:10,
																			columns: [[
																				{field:'id',title:'组长',width:80},
																				{field:'name',title:'姓名',width:120},
																			]],
																			fitColumns: true">
        </div>
 
        <div class="fitem">
            <label>检查专家:</label>
            <input id="expert" class="easyui-combogrid" style="width:175px" data-options="
																			panelWidth: 500,
																			idField: 'id',
																			textField: 'name',
																			url: 'bzjczj',
																			method: 'get',
																			rownumbers:true,
																			pagination:true,
																			pageSize:10,
																			columns: [[
																				{field:'id',title:'组长',width:80},
																				{field:'name',title:'姓名',width:120},
																			]],
																			fitColumns: true">
        </div>
 
        <div class="fitem">
            <label>企业名称:</label>
            <input id="entname" class="easyui-combogrid" style="width:175px" data-options="
																			panelWidth: 500,
																			idField: 'id',
																			textField: 'entName',
																			url: 'scztxx',
																			method: 'get',
																			rownumbers:true,
																			pagination:true,
																			pageSize:10,
																			columns: [[
																				{field:'id',title:'企业ID',width:80},
																				{field:'entName',title:'企业名称',width:80},
																				{field:'lerepName',title:'法人',width:120},
																			]],
																			fitColumns: true">
        </div>
 
        <div class="fitem">
            <label>检查事项:</label>
            <input id="checkItem" name="" class="easyui-textbox"  />
        </div>
        
        <div class="fitem">
            <label>接任务人:</label>
            <input id="acceptName" class="easyui-combogrid" style="width:175px" data-options="
																			panelWidth: 500,
																			idField: 'id',
																			textField: 'name',
																			url: 'bzjcry',
																			method: 'get',
																			rownumbers:true,
																			pagination:true,
																			pageSize:10,
																			columns: [[
																				{field:'id',title:'组长',width:80},
																				{field:'name',title:'姓名',width:120},
																			]],
																			fitColumns: true">
        </div>
        <!--直接写提交取消的事件不需要在js中绑定-->
        <div style="display: block;margin-top: 20px;text-align: center;" >
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-ok'" onclick="addCheck()" style="width: 90px">提交</a>
            <a href="javascript:void(0)" class="easyui-linkbutton c6" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#win').dialog('close')" style="width: 90px">取消</a>
        </div>
    </form>
    </div>
    
	<script type="text/javascript">
		/*添加监管企业信息*/
		function append(){
			$('#win').dialog('open');
		}
		
		function sign(){
			var selRow = $('#dg').datagrid('getSelected');
			if(selRow == null){
				$.messager.alert('错误提示','请选中一条数据!','error');
			}else{
				$.ajax({
					   type: "POST",
					   url: "sign/" + selRow.id,
					   success: function(data){
						   $("#dg").datagrid("reload");
					   }
					});
			}
		}
		/*签收*/
		function accept(){
			var selRow = $('#dg').datagrid('getSelected');
			if(selRow == null){
				$.messager.alert('错误提示','请选中一条数据!','error');
			}else{
				//ajax请求并回显数据
				$.ajax({
					   type: "POST",
					   url: "accepttask/" + selRow.id,
					   success: function(data){
						   $("#dg").datagrid("reload");
					   }
					});
			}
			
			
		}
		function removeit(){
			var selRow = $('#dg').datagrid('getSelected');
			if(selRow == null){
				$.messager.alert('错误提示','请选中一条数据!','error');
			}else{
				$.ajax({
					   type: "GET",
					   url: "deltask/" + selRow.id,
					   success: function(data){
						   if(data.code===200){
							   $("#dg").datagrid('reload');
						   }
					   }
					});
			}
		}
		function searchGep(){
			var datajosn = { "entname": $("#search").val()}
			$.ajax({
				   type: "GET",
				   url: "checklist",
				   data: datajosn,
				   success: function(data){
					   $("#dg").datagrid("loadData", data);
				   }
				});
		}
		function addCheck(){
			var datajosn = { 
					"name": $("#name").val(),
					"captain": $("#captain").combogrid("getText"),
					"member": $("#member").combogrid("getText"),
					"expert": $("#expert").combogrid("getText"),
					"entid": $("#entname").combogrid("getValue"),
					"entname": $("#entname").combogrid("getText"),
					"checkItem": $("#checkItem").val(),
					"acceptId": $("#acceptName").combogrid("getValue"),  //任务接收人ID
					"acceptName": $("#acceptName").combogrid("getText") //任务接收人姓名
					}
			$.ajax({
				   type: "POST",
				   url: "addCheck",
				   data: datajosn,
				   success: function(data){
					   console.log(data);
					   debugger
					   if(data.code===200){
						   $('#win').dialog('close');
						   $("#dg").datagrid('reload');
						   $.messager.alert('提示','添加成功!','info');
					   }
				   }
				});
		}
	</script>
</body>
</html>